﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HitachiLib.Data;

namespace HitachiApp.Model
{
    public class ScheduleUnitBaseModel
    {
        public ScheduleUnitBaseModel(int type)
        {
            Common = type == Schedule.HalfMonth;
        }

        private bool common;
        public bool Common
        {
            get { return common; }
            set { common = value; }
        }
        public bool Yearly
        {
            get { return !Common; }
        }

        public Visibility CommonVisibility
        {
            get
            {
                if (Common) return Visibility.Visible;
                else return Visibility.Collapsed;
            }
        }
        public Visibility YearlyVisibility
        {
            get
            {
                if (Common) return Visibility.Collapsed;
                else return Visibility.Visible;
            }
        }

        protected Schedule GetSchedule(Project project)
        {
            if (Common)
            {
                if (project.PlanSchedule.ContainsKey(Schedule.HalfMonth))
                    return project.PlanSchedule[Schedule.HalfMonth];
            }
            else
            {
                if (project.PlanSchedule.ContainsKey(Schedule.WholeYear))
                    return project.PlanSchedule[Schedule.WholeYear];
            }
            return null;
        }
    }
}
